package beans;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.Collection;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.ViewScoped;

import manager.ClipboardManager;

import structures.clipboard.ClipboardBaseParameter;
import structures.clipboard.IClipboardObject;

@ManagedBean(name="clipboardBean")
@ViewScoped
public class ClipboardBean implements Serializable {

	/**
	 * 
	 */
	private static final long serialVersionUID = 2034521810072512474L;
	
	private Collection<ClipboardBaseParameter> clipboardList;
	
	public ClipboardBean() {
		super();
		reloadList();
	}

	public void reloadList(){
		Collection<IClipboardObject> baseParameterList = 
				ClipboardManager.loadBaseParametersFromClipboard(false);

		clipboardList = new ArrayList<ClipboardBaseParameter>();
		
		for (IClipboardObject clipboardObject : baseParameterList) {
			clipboardList.add((ClipboardBaseParameter)clipboardObject);
		}
	}
	public void clearList(){
		ClipboardManager.clearBaseParametersFromClipboard();
		reloadList();
	}

	public Collection<ClipboardBaseParameter> getClipboardList() {
		return clipboardList;
	}

	public void setClipboardList(Collection<ClipboardBaseParameter> clipboardList) {
		this.clipboardList = clipboardList;
	}
	
	
}
